# -*- encoding: utf-8 -*-
from odoo import models, fields, api


class StockReturnPicking(models.TransientModel):
    _inherit = "stock.return.picking"

    return_reason = fields.Char(u'退货原因')

    @api.multi
    def _create_returns(self):
        new_picking_id, pick_type_id = super(StockReturnPicking, self)._create_returns()
        new_picking = self.env['stock.picking'].browse([new_picking_id])
        if new_picking and self.return_reason:
            new_picking.return_reason=self.return_reason
        return new_picking_id, pick_type_id

class StockPicking(models.Model):
    _inherit = 'stock.picking'

    return_reason = fields.Char(u'退货原因')
